Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

string-left-right

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-left-right

Looks up the first non-whitespace character to the left/right of a given index

  • 6.0.17
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
160K
increased by4.42%
Maintainers
1
Weekly downloads
 
Created

What is string-left-right?

The string-left-right npm package provides utilities for trimming whitespace from the left and right sides of strings, as well as other string manipulation functionalities.

What are string-left-right's main functionalities?

trimLeft

The trimLeft function removes whitespace from the left side of a string.

const { trimLeft } = require('string-left-right');
const result = trimLeft('   Hello World!   ');
console.log(result); // 'Hello World!   '

trimRight

The trimRight function removes whitespace from the right side of a string.

const { trimRight } = require('string-left-right');
const result = trimRight('   Hello World!   ');
console.log(result); // '   Hello World!'

trim

The trim function removes whitespace from both sides of a string.

const { trim } = require('string-left-right');
const result = trim('   Hello World!   ');
console.log(result); // 'Hello World!'

left

The left function returns the index of the first non-whitespace character from the left.

const { left } = require('string-left-right');
const result = left('   Hello World!   ');
console.log(result); // 3

right

The right function returns the index of the first non-whitespace character from the right.

const { right } = require('string-left-right');
const result = right('   Hello World!   ');
console.log(result); // 15

Other packages similar to string-left-right

Keywords

FAQs

Package last updated on 31 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc